package com.yuebao.config;

import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AlipayProperties {
    private String appId;
    private String appPrivateKey;
    private String alipayPublicKey;
    private String notifyUrl;
    
    private static final String GATEWAY_URL = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
    private static final String FORMAT = "JSON";
    private static final String CHARSET = "UTF-8";
    //签名方式
    private static final String SIGN_TYPE = "RSA2";
    
    @Bean
    public DefaultAlipayClient alipayAliPayClientBean(){
        return new DefaultAlipayClient(GATEWAY_URL, this.getAppId(),
                this.getAppPrivateKey(), FORMAT, CHARSET, this.getAlipayPublicKey(), SIGN_TYPE);
    }
    
}
